from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from mbserver.source.models import Source, Parser, Group

class ParserAdmin(admin.ModelAdmin):
    fieldsets = (
        (None, {'fields': ('name', 'description',)}),
        (_('File'), {'fields': ('type', 'file', 'regexp_title', 'regexp_description', 'regexp_link')}),
    )
    
    verbose_name = _('Parser')

class SourceAdmin(admin.ModelAdmin):
    fieldsets = (
        (None, {'fields': ('name', 'url','cache_expires')}),
        (_('Operators'), {'classes': ['collapse'], 'fields': ('op_and', 'op_or',)}),
        (_('Parser'), {'fields': ('parser',)}),
        (_('Groups'), {'fields': ('group',)})
    )

    verbose_name = _('Source')


class GroupAdmin(admin.ModelAdmin):
    verbose_name = _('Group')


admin.site.register(Parser, ParserAdmin)
admin.site.register(Source, SourceAdmin)
admin.site.register(Group, GroupAdmin)

